<template>
  <tbody >
    <tr v-for='(item,index) in goodList' :key='index'>
      <td><input type="checkbox" :checked="item.checked" @change='changeFn(index)'></td>
      <td>{{item.name}}</td>
      <td>{{item.price}}</td>
      <td>
        <button  @click='item.num>=1 ?reduceFn(index) :""'>-</button>
        {{item.num}} 
        <button @click='addFn(index)'>+</button>
      </td>
      <td>{{item.num*item.price}}</td>
      <td><button @click='delFn(index)'>删除</button></td>
    </tr>

  </tbody>
</template>

<script>
export default {
  props:{
     goodList:{
      type:Array,
      required:true
     }
  },
  data(){
    return{

      
    }

  },
  methods:{
    //减减  传索引
    reduceFn(index){
     this.$emit('reduceBtn',index)
    },
    //加加
    addFn(index){
      this.$emit('addBtn',index)
    },
    delFn(index){
      this.$emit('del',index)
    },
    changeFn(index){
      this.$emit('change',index)
    }
  },
  // computed:{
  //   get(){

  //   },
  //   set(val){
  //   this.$emit('',val)
  //   }
  // }

  


}
</script>

<style>

</style>